/**
 * <p>Title: ServiceZMCEF6.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 张志芳
 * @version 1.0
 * <pre>Histroy:
 *          2012-1-17 上午10:05:46  张志芳  Create
 *</pre>
 */
package com.baosight.sczx.zm.ce.service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baosight.iplat4j.core.ei.EiBlock;
import com.baosight.iplat4j.core.ei.EiColumn;
import com.baosight.iplat4j.core.ei.EiConstant;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.ep.ServiceEPBase;
import com.baosight.sczx.common.zm.basetools.StaticTools;
import com.baosight.sczx.common.zm.cInterface.Department;
import com.baosight.sczx.common.zm.cInterface.ce.Equipment;
import com.baosight.sczx.common.zm.cInterface.cs.Engineering;
import com.baosight.sczx.zm.ce.domain.ZMCEEquipmentDynamic;

/**
 * 变动记录
 * <p>Title: ServiceZMCEF6.java</p>
 * <p>Description: </p>
 * <p>Copyright: Baosight Software LTD.co Copyright (c) 2002</p>
 * <p>Company: Baosight Software</p>
 * @author 张志芳
 * @version 1.0
 * <pre>Histroy:
 *          2012-1-17 上午10:05:46  张志芳  Create
 *</pre>
 */
public class ServiceZMCEF6 extends ServiceEPBase {
	
	/**
	 * 初始化方法
	 * <p>Function: initLoad</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCE31</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-4-8上午09:57:14 张志芳
	 * </p>
	 *
	 */
	public EiInfo initLoad(EiInfo inInfo) {
		EiInfo outInfo = null;
		inInfo.addBlock(EiConstant.resultBlock).set("showCount", "true");//如果不加这个，翻页的统计和显示是错误的
		outInfo = query(inInfo);
		outInfo.addBlock(getMoveType());//变动类型
		outInfo.addBlock(Department.getInstance().getConstructionUnit("cmes.ce.department", "orgCode", "orgName", false));
		outInfo.addBlock(getEngineering());
		outInfo.addBlock(Equipment.getEquipmentBlock("cmes.ce.equipment", null));
		return outInfo;
	}

	/**
	 * 设备变动查询
	 * <p>Function: query</p>
	 * <p>Description: </p>
	 * <p>return value: ServiceZMCE31</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-1-26下午04:23:36 张志芳
	 * </p>
	 *
	 */
	@Override
	public EiInfo query(EiInfo inInfo) {
		String fdEquipmentId = inInfo.getString("fdEquipmentId");
		StaticTools.setQueryParameters(inInfo, "fdEquipmentId", fdEquipmentId, true);//添加查询条件	
		EiInfo outInfo = super.query(inInfo, "ZMCEEquipmentDynamic.query", new ZMCEEquipmentDynamic());				
		return outInfo;
	}
	
	
	/**
	 * 获取变动类型的下拉框
	 * <p>Function: getMoveType</p>
	 * <p>Description: </p>
	 * <p>return value:EiBlock</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-4-8下午01:10:09 张志芳
	 * </p>
	 *
	 */
	@SuppressWarnings("rawtypes")
	private EiBlock getMoveType()
	{
		EiBlock block = new EiBlock("cmes.ce.type");
		
		EiColumn eiColumn = new EiColumn("label");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("value");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		List<Map> list = new ArrayList<Map>();
		
		Map<String, String> _map;
		
		_map = new HashMap<String, String>();
		_map.put("value", "领用");
		_map.put("label", "领用");
		list.add(_map);
		
		_map = new HashMap<String, String>();
		_map.put("value", "启封");
		_map.put("label", "启封");
		list.add(_map);
		
		_map = new HashMap<String, String>();
		_map.put("value", "封存");
		_map.put("label", "封存");
		list.add(_map);
		
		_map = new HashMap<String, String>();
		_map.put("value", "移交");
		_map.put("label", "移交");
		list.add(_map);
		
		_map = new HashMap<String, String>();
		_map.put("value", "闲置");
		_map.put("label", "闲置");
		list.add(_map);
		
		_map = new HashMap<String, String>();
		_map.put("value", "报废");
		_map.put("label", "报废");
		list.add(_map);
		
		_map = new HashMap<String, String>();
		_map.put("value", "调拨");
		_map.put("label", "调拨");
		list.add(_map);		
		
		block.setRows(list);
		return block;
	}
	
	/**
	 * 获得工程
	 * <p>Function: getEngineering</p>
	 * <p>Description: </p>
	 * <p>return value:EiBlock</p>
	 * <p>throws Exception:</p>
	 * <p>History:
	 *    2011-1-21上午10:00:23 张志芳
	 * </p>
	 *
	 */
	@SuppressWarnings("rawtypes")
	private EiBlock getEngineering()
	{
		EiBlock block = new EiBlock("cmes.ce.engineering");
		
		EiColumn eiColumn = new EiColumn("fdKeyId");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		eiColumn = new EiColumn("fdName");
		eiColumn.setType("C");
		block.addMeta(eiColumn);
		
		List<Map> list = Engineering.getEngineerings(null);
		
		block.setRows(list);
		return block;
	}
	
}
